BX.namespace("BX.Main.SiteSpeed");BX.Main.SiteSpeed=function(){"use strict";var e=function(e,t){this.privateKey=e;this.accountId=t;this.statServerUrl=document.location.protocol+"//www.1c-bitrix.ru/buy_tmp/ba.php";this.invervals=[{title:BX.message("JS_SITE_SPEED_VERY_FAST"),color:"#d0df6c",inverval:500},{title:BX.message("JS_SITE_SPEED_FAST"),color:"#b3c636",inverval:1e3},{title:BX.message("JS_SITE_SPEED_NOT_FAST"),color:"#f0d53e",inverval:1500},{title:BX.message("JS_SITE_SPEED_SLOW"),color:"#f0b23e",inverval:2e3},{title:BX.message("JS_SITE_SPEED_VERY_SLOW"),color:"#f2921e",inverval:2500}]};e.prototype.drawIndicator=function(e,t){if(!e||e.result===false||!BX.type.isNumber(e.cnt)){return null}var a=BX.type.isNumber(e["p50"])?e["p50"]:-1;BX(t).style.display="block";var s=[];var i={label:""};var l=0;var r=0;for(var o=0;o<this.invervals.length;o++){r=Math.max(r,this.invervals[o].inverval);s.push({fillAlphas:.9,fontSize:11,labelText:this.invervals[o].title,lineAlpha:.5,color:"#000000",lineColor:this.invervals[o].color,title:this.invervals[o].title,type:"column",valueField:o});var n=this.invervals[o].inverval-l;l=this.invervals[o].inverval;i[o]=n}var p=AmCharts.makeChart(t,{type:"serial",theme:"none",rotate:true,dataProvider:[i],valueAxes:[{id:"intervals",stackType:"100%",axisAlpha:.5,gridAlpha:0,labelFunction:function(e,t,a){var s="";if(e===0){s="0"}else{if(e%20){return""}else{s=BX.Main.SiteSpeed.formatMilliseconds(e/100*r,1)}}return s+" "+BX.message("JS_SITE_SPEED_SECONDS_UNIT")}}],categoryField:"label",categoryAxis:{gridPosition:"start",axisAlpha:0,gridAlpha:0,position:"left"},graphs:s,marginTop:0,marginRight:15,marginLeft:10,marginBottom:30,autoMargins:false,chartCursor:{enabled:false}});if(a>0&&a<r){var d=p.getValueAxisById("intervals");var c=new AmCharts.Guide;c.value=a/r*100;c.lineColor="#000000";c.lineAlpha=1;c.fillAlpha=.2;c.fillColor="#000000";c.dashLength=4;c.inside=true;c.above=true;c.lineThickness=2;c.position="top";d.addGuide(c);p.validateNow()}return p};e.prototype.drawHisto=function(e,t){if(!e||e.result===false||!BX.type.isNumber(e.cnt)){return null}BX(t).style.display="block";var a=null;for(var s=0;s<e["steps"].length;s++){if(e["p50"]<e["steps"][s]){a=e["steps"][s-1];break}}if(a===null){a=e["steps"][e["steps"].length-1]}var i=[];for(var l in e["histo"]){var r=e["histo"][l]["cnt"];var o=e["histo"][l]["cmpCnt"];var n=r>0?(o/r*100).toFixed(1):0;i.push({cnt:r,title:l,cmpCnt:o,cmpPercent:n})}var p=this.invervals[this.invervals.length-1].color;for(s=0;s<this.invervals.length;s++){if(e["p50"]<this.invervals[s].inverval){p=this.invervals[s].color;break}}var d=AmCharts.makeChart(t,{type:"serial",theme:"none",pathToImages:"/bitrix/js/main/amcharts/3.21/images/",dataProvider:i,startDuration:1,balloon:{maxWidth:700,textAlign:"left"},graphs:[{balloonText:"<b>[[category]]: [[value]]</b>",balloonFunction:BX.proxy(function(t,a){var s=t.values["value"];var i=e["cnt"]>0?(s/e["cnt"]*100).toFixed(1):0;return"<b>"+BX.message("JS_SITE_SPEED_HITS")+": "+s+" ("+i+"%)</b><br><br>"+this.getStatTable(e["histo"][t["category"]]["hits"],"dit")},this),colorField:"color",fillAlphas:.9,lineAlpha:.2,lineColor:p,type:"column",valueField:"cnt"}],chartCursor:{categoryBalloonEnabled:false,cursorAlpha:0,zoomable:false},valueAxes:[{precision:0}],categoryField:"title",categoryAxis:{gridPosition:"start",labelFunction:function(e,t,a){return BX.Main.SiteSpeed.formatMilliseconds(e,1)+" "+BX.message("JS_SITE_SPEED_SECONDS_UNIT")},guides:[{category:a,lineColor:"#000000",lineAlpha:1,fillAlpha:.2,fillColor:"#CC0000",dashLength:2,inside:true,above:true,lineThickness:2,position:"top",labelRotation:90,label:BX.message("JS_SITE_SPEED_INDEX")}]},amExport:{}});if(BX.type.isNumber(e.compositeHits)&&e.compositeHits>0){d.addGraph({bullet:"round",lineThickness:3,bulletSize:7,bulletBorderAlpha:1,bulletColor:"#FFFFFF",useLineColorForBulletBorder:true,bulletBorderThickness:3,fillAlphas:0,lineAlpha:1,title:"Composite",valueField:"cmpCnt",balloonFunction:function(e,t){return BX.message("JS_SITE_SPEED_COMPOSITE_HITS")+": "+e.dataContext["cmpCnt"]+" ("+e.dataContext["cmpPercent"]+"%)"}})}return d};e.prototype.drawGraph=function(e,t){if(!BX.type.isArray(e)||e.length<1){return null}BX(t).style.display="block";AmCharts.shortMonthNames=[];for(var a=1;a<=12;a++){AmCharts.shortMonthNames.push(BX.message("MON_"+a))}return AmCharts.makeChart(t,{type:"serial",theme:"none",pathToImages:"/bitrix/js/main/amcharts/3.21/images/",dataDateFormat:"YYYY-MM-DD JJ:NN:SS",valueAxes:[{stackType:"regular",axisAlpha:0,position:"left",labelFunction:function(e,t,a){if(e==0){return 0}return BX.Main.SiteSpeed.formatMilliseconds(e,2)+" "+BX.message("JS_SITE_SPEED_SECONDS_UNIT")}}],legend:{equalWidths:true,position:"top",valueAlign:"left",markerType:"bubble",switchType:"v"},categoryField:"date_datetime",categoryAxis:{parseDates:true,equalSpacing:false,minPeriod:"ss",dateFormats:[{period:"fff",format:"JJ:NN"},{period:"ss",format:"JJ:NN"},{period:"mm",format:"JJ:NN"},{period:"hh",format:"JJ:NN"},{period:"DD",format:"MMM D"},{period:"WW",format:"MMM D"},{period:"MM",format:"MMM"},{period:"YYYY",format:"MMM"}]},dataProvider:e,balloon:{maxWidth:700,textAlign:"left"},graphs:[{hidden:true,fillAlphas:.6,lineAlpha:.4,title:"DNS",valueField:"dns",balloonText:""},{hidden:true,fillAlphas:.6,lineAlpha:.4,title:BX.message("JS_SITE_SPEED_TCP"),valueField:"tcp",balloonText:""},{fillAlphas:.6,lineAlpha:.4,title:BX.message("JS_SITE_SPEED_RESPONSE_TIME"),valueField:"srt",balloonText:""},{hidden:true,fillAlphas:.6,lineAlpha:.4,title:BX.message("JS_SITE_SPEED_DOWNLOAD_TIME"),valueField:"pdt",balloonText:""},{switchable:false,fillAlphas:.6,lineAlpha:.4,title:BX.message("JS_SITE_SPEED_PROCESSING_TIME"),valueField:"prc",balloonText:""},{stackable:false,switchable:true,lineAlpha:.4,title:BX.message("JS_SITE_SPEED_INTERACTIVE_TIME"),valueField:"dit",bullet:"round",lineThickness:3,bulletSize:7,bulletBorderAlpha:1,useLineColorForBulletBorder:true,bulletBorderThickness:3,balloonFunction:BX.proxy(function(e,t){var a=[["dit",BX.message("JS_SITE_SPEED_INTERACTIVE_TIME")],["srt",BX.message("JS_SITE_SPEED_RESPONSE_TIME")],["dns","DNS"],["tcp",BX.message("JS_SITE_SPEED_TCP")],["pdt",BX.message("JS_SITE_SPEED_DOWNLOAD_TIME")],["prc",BX.message("JS_SITE_SPEED_PROCESSING_TIME")]];var s='<div class="site-speed-balloon-stat">';for(var i=0;i<a.length;i++){var l=a[i][1];var r=typeof e.dataContext[a[i][0]]!=="undefined"?e.dataContext[a[i][0]]:-1;s+='<div class="site-speed-balloon-stat-item"><b>'+l+":</b>&nbsp;"+(r===0?0:BX.Main.SiteSpeed.formatMilliseconds(r,3))+" "+BX.message("JS_SITE_SPEED_SECONDS_UNIT")+"</div>"}s+="</div>";s+=this.getStatTable(e.dataContext["hits"],"dit");return s},this)}],plotAreaBorderAlpha:0,chartCursor:{cursorAlpha:1,zoomable:true,categoryBalloonEnabled:false}})};e.prototype.getHistoData=function(e,t,a){BX.ajax({method:"POST",dataType:"json",url:this.statServerUrl,data:{license:this.privateKey,op:"hit_attr_distrib",attr:"dit",domain:e,aid:this.accountId,tmz:(new Date).getTimezoneOffset()},onsuccess:t,onfailure:a})};e.prototype.getLastHits=function(e,t,a){BX.ajax({method:"POST",dataType:"json",url:this.statServerUrl,data:{license:this.privateKey,op:"domain_last_hits",domain:e,aid:this.accountId,tmz:(new Date).getTimezoneOffset()},onsuccess:t,onfailure:a})};e.prototype.getStatTable=function(e,t){if(!BX.type.isArray(e)){return""}var a='<table class="site-speed-hits-table">';a+="<tr>"+'<th class="site-speed-page-column">'+BX.message("JS_SITE_SPEED_PAGE")+"</th>"+'<th class="site-speed-interactive-column">'+BX.message("JS_SITE_SPEED_INTERACTIVE")+"</th>"+'<th class="site-speed-response-column">'+BX.message("JS_SITE_SPEED_RESPONSE")+"</th>"+'<th class="site-speed-processing-column">'+BX.message("JS_SITE_SPEED_PROCESSING")+"</th>"+'<th class="site-speed-composite-column">'+BX.message("JS_SITE_SPEED_COMPOSITE")+"</th>"+"</tr>";e.sort(function(e,a){if(parseInt(e[t])<parseInt(a[t])){return 1}if(parseInt(e[t])>parseInt(a[t])){return-1}return 0});for(var s=0;s<e.length;s++){var i=e[s];a+="<tr>"+'<td class="site-speed-page-column">'+(s+1)+".&nbsp;"+BX.util.htmlspecialchars(decodeURIComponent(i["ru"]))+"</td>"+'<td class="site-speed-interactive-column">'+BX.Main.SiteSpeed.formatMilliseconds(i["dit"],3)+"</td>"+'<td class="site-speed-response-column">'+BX.Main.SiteSpeed.formatMilliseconds(i["srt"],3)+"</td>"+'<td class="site-speed-processing-column">'+BX.Main.SiteSpeed.formatMilliseconds(i["prc"],3)+"</td>"+'<td class="site-speed-composite-column">'+(i["com"]==1?BX.message("JS_SITE_SPEED_COMPOSITE_YES"):BX.message("JS_SITE_SPEED_COMPOSITE_NO"))+"</td>"+"</tr>"}a+="</table>";return a};e.prototype.getInvervals=function(){return this.invervals};e.prototype.getInverval=function(e){for(var t=0;t<this.invervals.length;t++){if(e<this.invervals[t].inverval){return this.invervals[t]}}return this.invervals[this.invervals.length-1]};e.formatMilliseconds=function(e,t){e=parseInt(e,10);if(!BX.type.isNumber(e)||e<0){return-1}else if(e===0){return 0}t=t||2;return(e/1e3).toFixed(t)};return e}();
//# sourceMappingURL=site_speed.map.js